This article mainly introduces the case study of Mysql Performance Optimization-covering indexes and SQL _NO_CACHE. For more information, see
Scenario
The product has an image table pics with nearly 1 million data records and a related query statement. due to the high execution frequency, I want to optimize this statement.
The table structure is very simple. main fields:
The code is as follows:
User_id u
obviously the above SQL statements are not needed because the fields to select are in Idx_name_age. )
Explain SELECT Name,age,id,email from Test.users where age>50
This time did not use to idx_name_age, because to select the field contains the email, in idx_name_age there is no
Explain SELECT count (1) from Test.users where age>50
For a federated ind
| type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+------+---------------+----------+---------+-------+------+-------+
| 1 | Simple | user_group | ref | group_id | group_id | 4 | const | 5544 | |
+----+-------------+------------+------+---------------+----------+---------+-------+------+-------+ It looks like the index has been used, and this
A friend in csdn asked about the index coverage concept. This concept is very small. I have explained "" In My Forum. But as an oracle moderator, I cannot add an external Address link to the reply, so I will post a copy in csdn.
For example, a composite index has three fields: F1 + F2 + F3. Could you tell me:
1: Select F1, F2, F3, F4 from table where F1 = 'xx' and F2 = 'xx '.2: Select F1, F2, F3 from ta
Covering indexes is also called covering indexes.Interpretation 1: select data columns can be obtained only from the index without reading from the data table. In other words, the query column must be overwritten by the index used.Explanation 2: indexing is an efficient way to find rows. When you can retrieve the
Covering indexes of MySQL SQL optimization and optimizing indexes of mysqlsql
Content Overview
Using the primary index to improve SQL query efficiency is a frequently used technique, but sometimes the execution plan provided by MySQL is completely unexpected, we expect that MySQL will complete the query through
---- Set a non-primary key to clustered index [Step 4] to: http://king123654789.iteye.com/blog/1169191
1. View All indexes. Clustered indexes are created on the primary key by default.Sp_helpindex person
2. -- delete the primary key constraint and remove the index constraint on the primary key queried in [1], for example, PK _ person _ 117F9D94. Remove the primary key constraint from the primary key field
clustered index, nonclustered index, nonclustered unique indexWe all know that establishing an appropriate index can improve query speed and optimize queries. First, whether a clustered or nonclustered index is a B-tree structure .
The
clustered index matches th
Label:clustered index, nonclustered index, nonclustered unique index We all know that establishing an appropriate index can improve query speed and optimize queries. First, whether a clustered or nonclustered index is a B-tree structure .
The
clustered
in the data, you cannot create a unique index, a unique constraint, or a PRIMARY key constraint.
A unique nonclustered index can include a non-key column that contains sex.
a unique index relies on a unique constraint, and deleting a unique index must remove a unique constraint. In addition ,
Label:An index is an on-disk structure associated with a table or view, which speeds up the retrieval of rows from a table or view. An index contains keys that are generated by one or more columns in a table or view. These keys are stored in a structure (B-tree), allowing SQL Server to quickly and efficiently find the rows associated with the key value. A table o
) corresponding to the page number is also larger. If the phonetic "ha" corresponding to the word (Word) page number is more than the phonetic "ba" corresponding to the word (Word) page number. Nonclustered indexes (non-clustered) If it is not a clustered index, the physical order of the rows in the table does not match the logical order of the key values. Clustered indexes have faster data access speeds than nonclustered indexes (nonclustered
1. What is an aggregated index (clustered index)/What is a non-aggregated index (nonclustered)?The index can be understood as a special kind of directory. Microsoft's SQL Server provides two types of indexes: Clustered indexes (clustered
From: http://crm.xingfa.com/HelpDesk/Archiver.asp? Threadid = 8587 thanks to the author
2010-09-29 8:00:53
Let's take a simple look at how the SQL Server Index works. We will not talk about the index concepts.
Clustered index:
(Figure)
Let's look at figure A, the structure of the clustered index.T
= 'Green'
A non-clustered index graph of a relatively abstract point:
What is bookmark lookup?
Although bookmark lookup is no longer mentioned in SQL 2005 (changing the changes), many of our searches use such a search process as follows:Search in non-clustering and then in clustered index.
InHttp://www.sqlskills.com/In the example provided, we can see that
-clustered index:
Select*FromEmployeeWhereLname ='Green'
A non-clustered index graph of a relatively abstract point:
What is bookmark lookup?
Although bookmark lookup is no longer mentioned in SQL 2005 (changing the changes), many of our searches use such a search process as follows:Search in non-clustering and then in clustered
Basic SQL Server Index knowledge (2) ---- clustered index, non-clustered Index
[From] http://blog.joycode.com/ghj/archive/2008/01/02/113291.aspx
As I needed to train my colleagues on database indexing knowledge, I collected and sorted out this series of blogs. This is a summary of
point interesting?It shows that narrow (non-covering) nonclustered indexes have fewer uses than often expected (just because a query has a C Olumn in the WHERE clause doesn ' t mean which SQL Server ' s going to use that indexIt happens at a point that's typically much earlier than expected ... and, in fact, sometimes this is a VERY bad thing!Only nonclustered indexes of that does not cover a query have a
in the contact table. The following is the execution information.
SQL statement
SELECT FirstName, LastNameFROM dbo. Contacts -- execute with both Contacts_noindex and-- Contacts_indexWHERE LastName LIKE's %'
If no index is available
(2130 row (s) affected)Table 'contacts _ noindex'. Scan count 1, logical reads 568.
Indexing
(2130 row (s) affected)Table 'conta
history of the tables. However, the nonclustered index has an attribute, if you want to query the content, in the nonclustered index and is overwritten, you do not need to continue to the clustered index, or RID (row identifier in the heap structure) to find data, this time can greatly improve performance, this is the problem of coverage (
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.